﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;


namespace Bai01
{
    class DataProvider
    {
        public static DataTable executeQuery(string sql)
        {
            SqlConnection con = new SqlConnection();
            con.ConnectionString = @"Data Source=.\sqlexpress;Initial Catalog=BaiTap01;Integrated Security=True";
            con.Open();

            SqlDataAdapter adapter = new SqlDataAdapter(sql, con);
            DataTable dt = new DataTable();
            adapter.Fill(dt);

            con.Close();
            return dt;
        }

        public static void executeNonQuery(string sql)
        {
            SqlConnection con = new SqlConnection();
            con.ConnectionString = @"Data Source=.\sqlexpress;Initial Catalog=Can;Integrated Security=True";
            con.Open();

            SqlCommand command = new SqlCommand();
            command.Connection = con;
            command.CommandText = sql;
            command.ExecuteNonQuery();

            con.Close();
        }
    
    }
}
